package com.deliveryservicesystem.app.util.filechooser;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * File Name: ExclFilter.java
 * Version:
 * Description:
 * Package: com.deliveryservicesystem.app.util.filechooser
 * Author: Lance
 * Date: Jul 28, 2012
 * Editor:
 */
public class ExclFilter extends FileFilter
{

    @Override
    public boolean accept(File f)
    {
        if (f.isDirectory())
        {
            return true;
        }
        String extension = ChooserUtils.getExtension(f);
        if (extension != null)
        {
            if (extension.equals(ChooserUtils.xar)
                    || extension.equals(ChooserUtils.xl)
                    || extension.equals(ChooserUtils.xla)
                    || extension.equals(ChooserUtils.xlam)
                    || extension.equals(ChooserUtils.xlb)
                    || extension.equals(ChooserUtils.xlc)
                    || extension.equals(ChooserUtils.xll)
                    || extension.equals(ChooserUtils.xlm)
                    || extension.equals(ChooserUtils.xls)
                    || extension.equals(ChooserUtils.xlsb)
                    || extension.equals(ChooserUtils.xlsm)
                    || extension.equals(ChooserUtils.xlsx)
                    || extension.equals(ChooserUtils.xlt)
                    || extension.equals(ChooserUtils.xltm)
                    || extension.equals(ChooserUtils.xltx)
                    || extension.equals(ChooserUtils.xlw))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        return false;
    }

    //The description of this filter
    @Override
    public String getDescription()
    {
        return "Microsoft Excel";
    }
}
